EXCEPTION_ACCESS_VIOLATION during iteration?

Hi,  when I call my function this error apperas:

Object with id: "543"can not be deleted. During deletion process the followinf error appears:-R-E- DXL: <addins/services/deleteService.inc:80> An unexpected error has occurred: doors.exe caused an EXCEPTION_ACCESS_VIOLATION in module doors.exe at 0023:00DF2658

Row 80:

 

Object childObj
    for childObj in all o2BDeleted do { <-----row 80

Why this happens? I have access to read/write. In the before call I successfully delete an object.


Dinio - Thu Jan 21 04:41:57 EST 2016

Re: EXCEPTION_ACCESS_VIOLATION during iteration?
Mathias Mamsch - Thu Jan 21 05:35:47 EST 2016

If you get an access violation your object handle is somehow corrupt. This can happen, if you save it to a skip list or variable and then delete it and later access it, or something. So please verify that you do not access invalid handles.

Next possible problem can be DOORS internal structure problems - in which case flushDeletions() and refresh (Module) might give you peace. Regards, Mathias

Re: EXCEPTION_ACCESS_VIOLATION during iteration?
Dinio - Thu Jan 21 06:06:18 EST 2016

Mathias Mamsch - Thu Jan 21 05:35:47 EST 2016

If you get an access violation your object handle is somehow corrupt. This can happen, if you save it to a skip list or variable and then delete it and later access it, or something. So please verify that you do not access invalid handles.

Next possible problem can be DOORS internal structure problems - in which case flushDeletions() and refresh (Module) might give you peace. Regards, Mathias

I have all this kind of stuff. But can not detect the problem. This happens when have recursion and try to delete the children of parent object. If I have 1.3 ->1.3.1 -->1.3.3 etc and have a lot of recursive calls on 14 or more. With small numbers there is no problem.

When execute it directly in the DXLeditor there was no such kind of problems .

 

void deleteObject(Module mod, int id, bool isSoftDeletion) {
    printMessage (3, "Entering deleteObject function.\n")
    printMessage (3, "Try to delete object with id:" (quote(id "")) "\n")
    if (null id) error "The specified id null"
    if (null mod) error "The specified module is null"
      
    filtering off
    
    Object o2BDeleted = null
    Object o
    for o in mod do {
        int currentId = o."Absolute Number"
        if currentId == id then {
          o2BDeleted = o
          break
        }
    } 
   
    if (null o2BDeleted){
       error "No Object for deletion is found."
    }
   
    if (isSoftDeletion && isDeleted(o2BDeleted)) {
       error "The object is already deleted."
    }
   
    if (!canDelete(o2BDeleted)) {
       error "The object can not be deleted!!!"
    }
   
       // Delete outlinks because during deletion of the object an error can appears and 
       // then to lock the module. 
       printMessage (3, "Start deleting out-coming links. For the object with id:" (quote(id)"") "\n")
    Skip sk = create()
    Link L
    for L in all o2BDeleted->"*" do put(sk, L,L) 
    for L in sk do delete L
    flushDeletions()
    
    printMessage (3, "Start deleting  in-coming links. For the object with id:" (quote(id)"") "\n")
    //Delete incomming links
    LinkRef linkReferences
    ModName_ srcModRef
    for linkReferences in o2BDeleted<-"*" do {        
        srcModRef = source linkReferences
        if (!(open srcModRef)) {
            edit(fullName(srcModRef), false)
        }
    }

    Link inLink 
    for inLink in o2BDeleted<-"*" do {
        delete inLink
    }
    
    flushDeletions()
    refresh mod

    Object childObj
    for childObj in all o2BDeleted do {
            printMessage (3, "Start deleting child with id:" (quote(childObj."Absolute Number" "")) " of parent: "(quote(id)"") "\n")
            if (cell o2BDeleted || row o2BDeleted || isDeleted o2BDeleted) {
                printMessage (1, "Object is ignored from deletion it is sell or row in table:" (quote(id)"") "\n") 
                continue
            }
        int absNumber = childObj."Absolute Number"
        deleteObject (mod, absNumber, isSoftDeletion)
    }

     flushDeletions()
     refresh mod
     
     if(leaf(o2BDeleted)) {
        printMessage (3, "Check for descendents - id:" (quote(id ""))"\n")
        if (isSoftDeletion) {
             printMessage (3, "Execute softDelete on requirement with id:" (quote(id ""))"\n")
            softDelete(o2BDeleted)
           } elseif (isDeleted(o2BDeleted)) {
               printMessage (3, "Execute purge on softDeleted object:" (quote(id ""))"\n")
            purgeObject_ (o2BDeleted)
        } else {
            printMessage (3, "Executing hard deleting on object id:" (quote(o2BDeleted."Absolute Number" ""))"\n")
            hardDelete(o2BDeleted) 
        }
     flushDeletions()
     } else {
            printMessage (3, "Not leaf: id" (quote(o2BDeleted."Absolute Number" ""))"\n")
     }
     
}